/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/database/SPContacts.h,v 1.3 2003/11/21 12:39:24 itsme Exp $
 *
 *
 */


#ifndef __SPCONTACTS_H__

#include <windows.h>
#include "CeDatabase.h"

#include <string>
#include <vector>

typedef enum {
    CTX_WORK_NR,
    CTX_GSM_NR,
    CTX_HOME_NR,
    CTX_NR_TYPES,
} CTXNUMBERTYPE;

// each number contains the number, + the linetype.
class SPContactsEntry {
public:
    DWORD sysoid;        // refers to record in system-contacts db.
    std::string name;
    std::string number[CTX_NR_TYPES];
    std::string publicKey;     // public key identifying user.
};

typedef std::vector<SPContactsEntry> SPContactsEntryList;

class SPContacts {
public:
    SPContacts();
    ~SPContacts();

    void Open();

    bool FindEntriesByName(SPContactsEntryList &entrylist, const std::string& name);
    bool FindEntriesByNumber(SPContactsEntryList &entrylist, const std::string& number);

    bool AddEntry(const SPContactsEntry &entry);
    bool UpdateEntry(const SPContactsEntry &entry);

private:
        CeDatabase m_db;
    
    WCHAR *DatabaseName();
};

// database field id's
enum DBSPCONTACTS_FIELDS {
    DBSPCONTACTS_SYSOID_FIELD=1,
    DBSPCONTACTS_NUMBER_FIELD=3,
    DBSPCONTACTS_PUBLICKEY_FIELD=4,
};

#define __SPCONTACTS_H__
#endif
